#ifndef __CHARACTERS_LAYER_H__
#define __CHARACTERS_LAYER_H__

#include "cocos2d.h"
#include "cocos-ext.h"
#include "format.h"
USING_NS_CC;
USING_NS_CC_EXT;

#define ENTER_GAME_BUTTON_TAG	8
#define END_OF_TAG				9

#define TAG_TITLE_TEXT			11
#define TAG_TOP_TEXT			12
#define TAG_CHARACTER_IMAGE		13

#define PROSS_HP				14
#define PROSS_ATT				15
#define PROSS_DEF				16
#define PROSS_SPE				17

#define GUID_ERROR				-1
#define TOUCHED_ERROR			-99
class ChoseCharacterLayer : public Layer
{
public:
	ChoseCharacterLayer();
	~ChoseCharacterLayer();
	CREATE_FUNC(ChoseCharacterLayer);
	virtual bool init();
	void AddCharacterInfo(ChoseCharacterInfo __ChoseCharacterInfo);
	void IsLoadingFinish();
	void SetLoadedCharacter(ChosedCharacterDetail _ChosedCharacterDetail);

private:
	void InitCharacterTableView();
	virtual void update(float diff);
	virtual bool onTouchBegan(Touch *touch, Event *unused_event);
	virtual void onTouchMoved(Touch *touch, Event *unused_event);
	virtual void onTouchEnded(Touch *touch, Event *unused_event);
	void UpdateProssBar();
	int GetSelectedButton(Vec2 loc);
	void EnableTouchButton();
	void UpdateEnterGameButtonEnable();
	void UpdateCharacterDetailsToShow();
	void ResetButtonPostion(uint8 m_Touched);
	Size size;
	Vec2 VisableSize;
	Vec2 OrginSize;

	float BaseButtonPosX;
	float EnableButtonPosX;
	bool IsLoadFinish;
	bool IsCharacterLoadFinish;
	Sprite* CellBackGround;
	LabelTTF* CellTitleText;
	std::vector<ChoseCharacterInfo> _ChoseCharacterInfo;
	bool CanTouchButton;
	uint8 m_TouchedButton;

	uint32 ChoseedCharacterGuid;
	bool CanEnterGame;
	uint8 Class;
	ChosedCharacterDetail _ChosedCharacterDetail;

	Sprite* LeftFrame;
	Sprite* Left_Power_Title;
	Sprite* BackGround;
	Sprite* _EnterButton;
	Sprite* EnterButton_Text;
	Sprite* Create_To_Create_New_Character;
	Sprite* TopTitle;
	Sprite* TopText;
	Sprite* CharacterImage;

	std::vector<CCProgressTimer*> PorgressVector;
};
#endif